import { lazy,Suspense } from "react"
import { Navigate, useRoutes } from "react-router-dom"

const Todo = lazy(()=>import('../pages/Todo'))

const comp = (Comp)=>{
    return <Suspense backfall={<div>加载中</div>}>
        <Comp/>
    </Suspense>
}


const root = [
    {
        path:'/todo',
        element:comp(Todo)
    },
    {
        path:"/",
        element:<Navigate to={"/todo"}/>
    },
    {
        path:'*',
        element:<Navigate to={"/todo"}/>
    }
]



export default root

export const GetRoute = ()=>{
    return useRoutes(root)
}